/***************************************************************************
 *            util.h
 *
 *  jue junio 14 19:29:34 2012
 *  Copyright  2012  Kellerman Rivero
 *  <user@host>
 ****************************************************************************/
/*
 * util.h
 *
 * Copyright (C) 2012 - Kellerman Rivero
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef UTIL_H
#define UTIL_H

#include <stdlib.h>
#include <stdio.h>

#define LISTA(a) ((Lista**)&a)
#define NODO(a)  ((Lista*)a)


typedef struct {
	void *algo;
	void *siguiente;
} Lista;

Lista* (*crearNodo)(Lista *nodo, Lista *siguiente, void* data);
int (*Criterio)(void*,void*,int);
void (*Imprimir)(void*);
typedef struct _str_listajugador {
	struct _str_jugador* jugador;
	struct _str_listajugador* siguiente;
} ListaJugador;

typedef struct _str_sala {
	unsigned int id;
	unsigned int capacidad;
	unsigned int minELO;
	unsigned int maxELO;
	struct _str_listajugador* jugadores;
	struct _str_listapartida* partidas;
} Sala;

typedef struct _str_partida {
	unsigned int tablero[64];
	unsigned int id;
	char** jugadas;
	struct _str_jugador* blancas;
	struct _str_jugador* negras;
	struct _str_listajugador* observadores;
} Partida;

typedef struct _str_listapartida{
	struct _str_partida* partida;
	struct _str_listapartida* siguiente;
} ListaPartida;


typedef struct _str_jugador {
	unsigned int id;
	char usuario[256];
	char nombres[50];
	unsigned int edad;
	unsigned int pais;
	unsigned int elo;
	unsigned int p_ganadas;
	unsigned int p_perdidas;
	unsigned int p_tablas;
	int* avatar;
	struct _str_sala* sala;
} Jugador;


enum Piezas { Peon=1,Caballo, Alfil, Torre, Dama, Rey };
enum ModoComparacion {ComparacionSimple=0,ComparacionFull};

Lista *Lista_InsertarInicio(Lista**,void*);
Lista *Lista_EliminarInicio(Lista**);
Lista *Lista_InsertarFinal (Lista**,void*);
Lista *Lista_EliminarFinal (Lista**);
Lista *Lista_Liberar(Lista**);
Lista *Lista_Inicializar(Lista**);
Lista *Lista_Eliminar(Lista**, void*, int (*Criterio)(void*,void*,int), int*);
Lista *Lista_BusquedaSimple(Lista**, void*, int(*Criterio)(void*,void*,int),int*,int*);
Lista *Lista_BusquedaFull(Lista**, void*, int(*Criterio)(void*,void*,int),int*,int*);
void Lista_Imprimir (Lista**,void (*Imprimir)(void*));
#endif